3.1.87 \(\int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx\) [87]

3.1.87.1 Optimal result
3.1.87.2 Mathematica [C] (verified)
3.1.87.3 Rubi [A] (verified)
3.1.87.4 Maple [A] (verified)
3.1.87.5 Fricas [B] (verification not implemented)
3.1.87.6 Sympy [F(-2)]
3.1.87.7 Maxima [A] (verification not implemented)
3.1.87.8 Giac [B] (verification not implemented)
3.1.87.9 Mupad [B] (verification not implemented)

3.1.87.1 Optimal result

Integrand size = 33, antiderivative size = 209 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx=-\frac {\left (c^3 C-3 B c^2 d-3 c C d^2+B d^3-A \left (c^3-3 c d^2\right )\right ) x}{\left (c^2+d^2\right )^3}+\frac {\left ((A-C) d \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{\left (c^2+d^2\right )^3 f}-\frac {c^2 C-B c d+A d^2}{2 d \left (c^2+d^2\right ) f (c+d \tan (e+f x))^2}-\frac {2 c (A-C) d-B \left (c^2-d^2\right )}{\left (c^2+d^2\right )^2 f (c+d \tan (e+f x))} \]

output
-(c^3*C-3*B*c^2*d-3*C*c*d^2+B*d^3-A*(c^3-3*c*d^2))*x/(c^2+d^2)^3+((A-C)*d* 
(3*c^2-d^2)-B*(c^3-3*c*d^2))*ln(c*cos(f*x+e)+d*sin(f*x+e))/(c^2+d^2)^3/f+1 
/2*(-A*d^2+B*c*d-C*c^2)/d/(c^2+d^2)/f/(c+d*tan(f*x+e))^2+(-2*c*(A-C)*d+B*( 
c^2-d^2))/(c^2+d^2)^2/f/(c+d*tan(f*x+e))
 
3.1.87.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 5.52 (sec) , antiderivative size = 261, normalized size of antiderivative = 1.25 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx=-\frac {\frac {C}{(c+d \tan (e+f x))^2}+B \left (\frac {i \log (i-\tan (e+f x))}{(c+i d)^2}-\frac {i \log (i+\tan (e+f x))}{(c-i d)^2}+\frac {2 d \left (-2 c \log (c+d \tan (e+f x))+\frac {c^2+d^2}{c+d \tan (e+f x)}\right )}{\left (c^2+d^2\right )^2}\right )-(B c+(-A+C) d) \left (\frac {i \log (i-\tan (e+f x))}{(c+i d)^3}-\frac {\log (i+\tan (e+f x))}{(i c+d)^3}+\frac {d \left (\left (-6 c^2+2 d^2\right ) \log (c+d \tan (e+f x))+\frac {\left (c^2+d^2\right ) \left (5 c^2+d^2+4 c d \tan (e+f x)\right )}{(c+d \tan (e+f x))^2}\right )}{\left (c^2+d^2\right )^3}\right )}{2 d f} \]

input
Integrate[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x])^3,x 
]
 
output
-1/2*(C/(c + d*Tan[e + f*x])^2 + B*((I*Log[I - Tan[e + f*x]])/(c + I*d)^2 
- (I*Log[I + Tan[e + f*x]])/(c - I*d)^2 + (2*d*(-2*c*Log[c + d*Tan[e + f*x 
]] + (c^2 + d^2)/(c + d*Tan[e + f*x])))/(c^2 + d^2)^2) - (B*c + (-A + C)*d 
)*((I*Log[I - Tan[e + f*x]])/(c + I*d)^3 - Log[I + Tan[e + f*x]]/(I*c + d) 
^3 + (d*((-6*c^2 + 2*d^2)*Log[c + d*Tan[e + f*x]] + ((c^2 + d^2)*(5*c^2 + 
d^2 + 4*c*d*Tan[e + f*x]))/(c + d*Tan[e + f*x])^2))/(c^2 + d^2)^3))/(d*f)
 
3.1.87.3 Rubi [A] (verified)

Time = 0.94 (sec) , antiderivative size = 234, normalized size of antiderivative = 1.12, number of steps used = 9, number of rules used = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.273, Rules used = {3042, 4111, 3042, 4012, 25, 3042, 4014, 3042, 4013}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {A+B \tan (e+f x)+C \tan (e+f x)^2}{(c+d \tan (e+f x))^3}dx\)

\(\Big \downarrow \) 4111

\(\displaystyle \frac {\int \frac {A c-C c+B d+(B c-(A-C) d) \tan (e+f x)}{(c+d \tan (e+f x))^2}dx}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{2 d f \left (c^2+d^2\right ) (c+d \tan (e+f x))^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \frac {A c-C c+B d+(B c-(A-C) d) \tan (e+f x)}{(c+d \tan (e+f x))^2}dx}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{2 d f \left (c^2+d^2\right ) (c+d \tan (e+f x))^2}\)

\(\Big \downarrow \) 4012

\(\displaystyle \frac {\frac {\int -\frac {C c^2-2 B d c-C d^2-A \left (c^2-d^2\right )+\left (2 c (A-C) d-B \left (c^2-d^2\right )\right ) \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {2 c d (A-C)-B \left (c^2-d^2\right )}{f \left (c^2+d^2\right ) (c+d \tan (e+f x))}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{2 d f \left (c^2+d^2\right ) (c+d \tan (e+f x))^2}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {-\frac {\int \frac {C c^2-2 B d c-C d^2-A \left (c^2-d^2\right )+\left (2 c (A-C) d-B \left (c^2-d^2\right )\right ) \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {2 c d (A-C)-B \left (c^2-d^2\right )}{f \left (c^2+d^2\right ) (c+d \tan (e+f x))}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{2 d f \left (c^2+d^2\right ) (c+d \tan (e+f x))^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {-\frac {\int \frac {C c^2-2 B d c-C d^2-A \left (c^2-d^2\right )+\left (2 c (A-C) d-B \left (c^2-d^2\right )\right ) \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {2 c d (A-C)-B \left (c^2-d^2\right )}{f \left (c^2+d^2\right ) (c+d \tan (e+f x))}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{2 d f \left (c^2+d^2\right ) (c+d \tan (e+f x))^2}\)

\(\Big \downarrow \) 4014

\(\displaystyle \frac {-\frac {-\frac {\left (d (A-C) \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right ) \int \frac {d-c \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {x \left (A c^3-3 A c d^2+3 B c^2 d-B d^3-c^3 C+3 c C d^2\right )}{c^2+d^2}}{c^2+d^2}-\frac {2 c d (A-C)-B \left (c^2-d^2\right )}{f \left (c^2+d^2\right ) (c+d \tan (e+f x))}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{2 d f \left (c^2+d^2\right ) (c+d \tan (e+f x))^2}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {-\frac {-\frac {\left (d (A-C) \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right ) \int \frac {d-c \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {x \left (A c^3-3 A c d^2+3 B c^2 d-B d^3-c^3 C+3 c C d^2\right )}{c^2+d^2}}{c^2+d^2}-\frac {2 c d (A-C)-B \left (c^2-d^2\right )}{f \left (c^2+d^2\right ) (c+d \tan (e+f x))}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{2 d f \left (c^2+d^2\right ) (c+d \tan (e+f x))^2}\)

\(\Big \downarrow \) 4013

\(\displaystyle \frac {-\frac {2 c d (A-C)-B \left (c^2-d^2\right )}{f \left (c^2+d^2\right ) (c+d \tan (e+f x))}-\frac {-\frac {\left (d (A-C) \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{f \left (c^2+d^2\right )}-\frac {x \left (A c^3-3 A c d^2+3 B c^2 d-B d^3-c^3 C+3 c C d^2\right )}{c^2+d^2}}{c^2+d^2}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{2 d f \left (c^2+d^2\right ) (c+d \tan (e+f x))^2}\)

input
Int[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x])^3,x]
 
output
-1/2*(c^2*C - B*c*d + A*d^2)/(d*(c^2 + d^2)*f*(c + d*Tan[e + f*x])^2) + (- 
((-(((A*c^3 - c^3*C + 3*B*c^2*d - 3*A*c*d^2 + 3*c*C*d^2 - B*d^3)*x)/(c^2 + 
 d^2)) - (((A - C)*d*(3*c^2 - d^2) - B*(c^3 - 3*c*d^2))*Log[c*Cos[e + f*x] 
 + d*Sin[e + f*x]])/((c^2 + d^2)*f))/(c^2 + d^2)) - (2*c*(A - C)*d - B*(c^ 
2 - d^2))/((c^2 + d^2)*f*(c + d*Tan[e + f*x])))/(c^2 + d^2)
 

3.1.87.3.1 Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4012
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)]), x_Symbol] :> Simp[(b*c - a*d)*((a + b*Tan[e + f*x])^(m + 1)/ 
(f*(m + 1)*(a^2 + b^2))), x] + Simp[1/(a^2 + b^2)   Int[(a + b*Tan[e + f*x] 
)^(m + 1)*Simp[a*c + b*d - (b*c - a*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a 
, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && LtQ[m, -1 
]
 

rule 4013
Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)* 
(x_)]), x_Symbol] :> Simp[(c/(b*f))*Log[RemoveContent[a*Cos[e + f*x] + b*Si 
n[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && 
 NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]
 

rule 4014
Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_. 
)*(x_)]), x_Symbol] :> Simp[(a*c + b*d)*(x/(a^2 + b^2)), x] + Simp[(b*c - a 
*d)/(a^2 + b^2)   Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x] /; 
FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && N 
eQ[a*c + b*d, 0]
 

rule 4111
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + 
 (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[(A*b^2 - 
 a*b*B + a^2*C)*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1)*(a^2 + b^2))), x 
] + Simp[1/(a^2 + b^2)   Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[b*B + a*(A - 
 C) - (A*b - a*B - b*C)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, e, f, A, B 
, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && LtQ[m, -1] && NeQ[a^2 + b^2, 0 
]
 
3.1.87.4 Maple [A] (verified)

Time = 0.14 (sec) , antiderivative size = 262, normalized size of antiderivative = 1.25

method result size
derivativedivides \(\frac {\frac {\frac {\left (-3 A \,c^{2} d +A \,d^{3}+B \,c^{3}-3 B c \,d^{2}+3 C \,c^{2} d -C \,d^{3}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,c^{3}-3 A c \,d^{2}+3 B \,c^{2} d -B \,d^{3}-c^{3} C +3 C c \,d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{3}}-\frac {A \,d^{2}-B c d +c^{2} C}{2 \left (c^{2}+d^{2}\right ) d \left (c +d \tan \left (f x +e \right )\right )^{2}}-\frac {2 A d c -B \,c^{2}+d^{2} B -2 C c d}{\left (c^{2}+d^{2}\right )^{2} \left (c +d \tan \left (f x +e \right )\right )}+\frac {\left (3 A \,c^{2} d -A \,d^{3}-B \,c^{3}+3 B c \,d^{2}-3 C \,c^{2} d +C \,d^{3}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{3}}}{f}\) \(262\)
default \(\frac {\frac {\frac {\left (-3 A \,c^{2} d +A \,d^{3}+B \,c^{3}-3 B c \,d^{2}+3 C \,c^{2} d -C \,d^{3}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,c^{3}-3 A c \,d^{2}+3 B \,c^{2} d -B \,d^{3}-c^{3} C +3 C c \,d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{3}}-\frac {A \,d^{2}-B c d +c^{2} C}{2 \left (c^{2}+d^{2}\right ) d \left (c +d \tan \left (f x +e \right )\right )^{2}}-\frac {2 A d c -B \,c^{2}+d^{2} B -2 C c d}{\left (c^{2}+d^{2}\right )^{2} \left (c +d \tan \left (f x +e \right )\right )}+\frac {\left (3 A \,c^{2} d -A \,d^{3}-B \,c^{3}+3 B c \,d^{2}-3 C \,c^{2} d +C \,d^{3}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{3}}}{f}\) \(262\)
norman \(\frac {\frac {\left (A \,c^{3}-3 A c \,d^{2}+3 B \,c^{2} d -B \,d^{3}-c^{3} C +3 C c \,d^{2}\right ) c^{2} x}{\left (c^{4}+2 c^{2} d^{2}+d^{4}\right ) \left (c^{2}+d^{2}\right )}+\frac {d^{2} \left (A \,c^{3}-3 A c \,d^{2}+3 B \,c^{2} d -B \,d^{3}-c^{3} C +3 C c \,d^{2}\right ) x \tan \left (f x +e \right )^{2}}{\left (c^{4}+2 c^{2} d^{2}+d^{4}\right ) \left (c^{2}+d^{2}\right )}-\frac {5 A \,c^{2} d^{3}+A \,d^{5}-3 B \,c^{3} d^{2}+B c \,d^{4}+C \,c^{4} d -3 C \,c^{2} d^{3}}{2 f \,d^{2} \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {\left (2 A c \,d^{3}-B \,c^{2} d^{2}+d^{4} B -2 c C \,d^{3}\right ) \tan \left (f x +e \right )}{f d \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}+\frac {2 d \left (A \,c^{3}-3 A c \,d^{2}+3 B \,c^{2} d -B \,d^{3}-c^{3} C +3 C c \,d^{2}\right ) c x \tan \left (f x +e \right )}{\left (c^{4}+2 c^{2} d^{2}+d^{4}\right ) \left (c^{2}+d^{2}\right )}}{\left (c +d \tan \left (f x +e \right )\right )^{2}}+\frac {\left (3 A \,c^{2} d -A \,d^{3}-B \,c^{3}+3 B c \,d^{2}-3 C \,c^{2} d +C \,d^{3}\right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{f \left (c^{6}+3 c^{4} d^{2}+3 c^{2} d^{4}+d^{6}\right )}-\frac {\left (3 A \,c^{2} d -A \,d^{3}-B \,c^{3}+3 B c \,d^{2}-3 C \,c^{2} d +C \,d^{3}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f \left (c^{6}+3 c^{4} d^{2}+3 c^{2} d^{4}+d^{6}\right )}\) \(529\)
risch \(\text {Expression too large to display}\) \(1176\)
parallelrisch \(\text {Expression too large to display}\) \(1348\)

input
int((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x,method=_RETURNVER 
BOSE)
 
output
1/f*(1/(c^2+d^2)^3*(1/2*(-3*A*c^2*d+A*d^3+B*c^3-3*B*c*d^2+3*C*c^2*d-C*d^3) 
*ln(1+tan(f*x+e)^2)+(A*c^3-3*A*c*d^2+3*B*c^2*d-B*d^3-C*c^3+3*C*c*d^2)*arct 
an(tan(f*x+e)))-1/2*(A*d^2-B*c*d+C*c^2)/(c^2+d^2)/d/(c+d*tan(f*x+e))^2-(2* 
A*c*d-B*c^2+B*d^2-2*C*c*d)/(c^2+d^2)^2/(c+d*tan(f*x+e))+(3*A*c^2*d-A*d^3-B 
*c^3+3*B*c*d^2-3*C*c^2*d+C*d^3)/(c^2+d^2)^3*ln(c+d*tan(f*x+e)))
 
3.1.87.5 Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 566 vs. \(2 (207) = 414\).

Time = 0.30 (sec) , antiderivative size = 566, normalized size of antiderivative = 2.71 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx=-\frac {3 \, C c^{4} d - 5 \, B c^{3} d^{2} + {\left (7 \, A - 3 \, C\right )} c^{2} d^{3} + B c d^{4} + A d^{5} - 2 \, {\left ({\left (A - C\right )} c^{5} + 3 \, B c^{4} d - 3 \, {\left (A - C\right )} c^{3} d^{2} - B c^{2} d^{3}\right )} f x - {\left (C c^{4} d - 3 \, B c^{3} d^{2} + 5 \, {\left (A - C\right )} c^{2} d^{3} + 3 \, B c d^{4} - A d^{5} + 2 \, {\left ({\left (A - C\right )} c^{3} d^{2} + 3 \, B c^{2} d^{3} - 3 \, {\left (A - C\right )} c d^{4} - B d^{5}\right )} f x\right )} \tan \left (f x + e\right )^{2} + {\left (B c^{5} - 3 \, {\left (A - C\right )} c^{4} d - 3 \, B c^{3} d^{2} + {\left (A - C\right )} c^{2} d^{3} + {\left (B c^{3} d^{2} - 3 \, {\left (A - C\right )} c^{2} d^{3} - 3 \, B c d^{4} + {\left (A - C\right )} d^{5}\right )} \tan \left (f x + e\right )^{2} + 2 \, {\left (B c^{4} d - 3 \, {\left (A - C\right )} c^{3} d^{2} - 3 \, B c^{2} d^{3} + {\left (A - C\right )} c d^{4}\right )} \tan \left (f x + e\right )\right )} \log \left (\frac {d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - 2 \, {\left (C c^{5} - 2 \, B c^{4} d + 3 \, {\left (A - C\right )} c^{3} d^{2} + 3 \, B c^{2} d^{3} - {\left (3 \, A - 2 \, C\right )} c d^{4} - B d^{5} + 2 \, {\left ({\left (A - C\right )} c^{4} d + 3 \, B c^{3} d^{2} - 3 \, {\left (A - C\right )} c^{2} d^{3} - B c d^{4}\right )} f x\right )} \tan \left (f x + e\right )}{2 \, {\left ({\left (c^{6} d^{2} + 3 \, c^{4} d^{4} + 3 \, c^{2} d^{6} + d^{8}\right )} f \tan \left (f x + e\right )^{2} + 2 \, {\left (c^{7} d + 3 \, c^{5} d^{3} + 3 \, c^{3} d^{5} + c d^{7}\right )} f \tan \left (f x + e\right ) + {\left (c^{8} + 3 \, c^{6} d^{2} + 3 \, c^{4} d^{4} + c^{2} d^{6}\right )} f\right )}} \]

input
integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x, algorithm= 
"fricas")
 
output
-1/2*(3*C*c^4*d - 5*B*c^3*d^2 + (7*A - 3*C)*c^2*d^3 + B*c*d^4 + A*d^5 - 2* 
((A - C)*c^5 + 3*B*c^4*d - 3*(A - C)*c^3*d^2 - B*c^2*d^3)*f*x - (C*c^4*d - 
 3*B*c^3*d^2 + 5*(A - C)*c^2*d^3 + 3*B*c*d^4 - A*d^5 + 2*((A - C)*c^3*d^2 
+ 3*B*c^2*d^3 - 3*(A - C)*c*d^4 - B*d^5)*f*x)*tan(f*x + e)^2 + (B*c^5 - 3* 
(A - C)*c^4*d - 3*B*c^3*d^2 + (A - C)*c^2*d^3 + (B*c^3*d^2 - 3*(A - C)*c^2 
*d^3 - 3*B*c*d^4 + (A - C)*d^5)*tan(f*x + e)^2 + 2*(B*c^4*d - 3*(A - C)*c^ 
3*d^2 - 3*B*c^2*d^3 + (A - C)*c*d^4)*tan(f*x + e))*log((d^2*tan(f*x + e)^2 
 + 2*c*d*tan(f*x + e) + c^2)/(tan(f*x + e)^2 + 1)) - 2*(C*c^5 - 2*B*c^4*d 
+ 3*(A - C)*c^3*d^2 + 3*B*c^2*d^3 - (3*A - 2*C)*c*d^4 - B*d^5 + 2*((A - C) 
*c^4*d + 3*B*c^3*d^2 - 3*(A - C)*c^2*d^3 - B*c*d^4)*f*x)*tan(f*x + e))/((c 
^6*d^2 + 3*c^4*d^4 + 3*c^2*d^6 + d^8)*f*tan(f*x + e)^2 + 2*(c^7*d + 3*c^5* 
d^3 + 3*c^3*d^5 + c*d^7)*f*tan(f*x + e) + (c^8 + 3*c^6*d^2 + 3*c^4*d^4 + c 
^2*d^6)*f)
 
3.1.87.6 Sympy [F(-2)]

Exception generated. \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx=\text {Exception raised: AttributeError} \]

input
integrate((A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f*x+e))**3,x)
 
output
Exception raised: AttributeError >> 'NoneType' object has no attribute 'pr 
imitive'
 
3.1.87.7 Maxima [A] (verification not implemented)

Time = 0.33 (sec) , antiderivative size = 367, normalized size of antiderivative = 1.76 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx=\frac {\frac {2 \, {\left ({\left (A - C\right )} c^{3} + 3 \, B c^{2} d - 3 \, {\left (A - C\right )} c d^{2} - B d^{3}\right )} {\left (f x + e\right )}}{c^{6} + 3 \, c^{4} d^{2} + 3 \, c^{2} d^{4} + d^{6}} - \frac {2 \, {\left (B c^{3} - 3 \, {\left (A - C\right )} c^{2} d - 3 \, B c d^{2} + {\left (A - C\right )} d^{3}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{6} + 3 \, c^{4} d^{2} + 3 \, c^{2} d^{4} + d^{6}} + \frac {{\left (B c^{3} - 3 \, {\left (A - C\right )} c^{2} d - 3 \, B c d^{2} + {\left (A - C\right )} d^{3}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{6} + 3 \, c^{4} d^{2} + 3 \, c^{2} d^{4} + d^{6}} - \frac {C c^{4} - 3 \, B c^{3} d + {\left (5 \, A - 3 \, C\right )} c^{2} d^{2} + B c d^{3} + A d^{4} - 2 \, {\left (B c^{2} d^{2} - 2 \, {\left (A - C\right )} c d^{3} - B d^{4}\right )} \tan \left (f x + e\right )}{c^{6} d + 2 \, c^{4} d^{3} + c^{2} d^{5} + {\left (c^{4} d^{3} + 2 \, c^{2} d^{5} + d^{7}\right )} \tan \left (f x + e\right )^{2} + 2 \, {\left (c^{5} d^{2} + 2 \, c^{3} d^{4} + c d^{6}\right )} \tan \left (f x + e\right )}}{2 \, f} \]

input
integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x, algorithm= 
"maxima")
 
output
1/2*(2*((A - C)*c^3 + 3*B*c^2*d - 3*(A - C)*c*d^2 - B*d^3)*(f*x + e)/(c^6 
+ 3*c^4*d^2 + 3*c^2*d^4 + d^6) - 2*(B*c^3 - 3*(A - C)*c^2*d - 3*B*c*d^2 + 
(A - C)*d^3)*log(d*tan(f*x + e) + c)/(c^6 + 3*c^4*d^2 + 3*c^2*d^4 + d^6) + 
 (B*c^3 - 3*(A - C)*c^2*d - 3*B*c*d^2 + (A - C)*d^3)*log(tan(f*x + e)^2 + 
1)/(c^6 + 3*c^4*d^2 + 3*c^2*d^4 + d^6) - (C*c^4 - 3*B*c^3*d + (5*A - 3*C)* 
c^2*d^2 + B*c*d^3 + A*d^4 - 2*(B*c^2*d^2 - 2*(A - C)*c*d^3 - B*d^4)*tan(f* 
x + e))/(c^6*d + 2*c^4*d^3 + c^2*d^5 + (c^4*d^3 + 2*c^2*d^5 + d^7)*tan(f*x 
 + e)^2 + 2*(c^5*d^2 + 2*c^3*d^4 + c*d^6)*tan(f*x + e)))/f
 
3.1.87.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 531 vs. \(2 (207) = 414\).

Time = 0.69 (sec) , antiderivative size = 531, normalized size of antiderivative = 2.54 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx=\frac {\frac {2 \, {\left (A c^{3} - C c^{3} + 3 \, B c^{2} d - 3 \, A c d^{2} + 3 \, C c d^{2} - B d^{3}\right )} {\left (f x + e\right )}}{c^{6} + 3 \, c^{4} d^{2} + 3 \, c^{2} d^{4} + d^{6}} + \frac {{\left (B c^{3} - 3 \, A c^{2} d + 3 \, C c^{2} d - 3 \, B c d^{2} + A d^{3} - C d^{3}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{6} + 3 \, c^{4} d^{2} + 3 \, c^{2} d^{4} + d^{6}} - \frac {2 \, {\left (B c^{3} d - 3 \, A c^{2} d^{2} + 3 \, C c^{2} d^{2} - 3 \, B c d^{3} + A d^{4} - C d^{4}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{6} d + 3 \, c^{4} d^{3} + 3 \, c^{2} d^{5} + d^{7}} + \frac {3 \, B c^{3} d^{3} \tan \left (f x + e\right )^{2} - 9 \, A c^{2} d^{4} \tan \left (f x + e\right )^{2} + 9 \, C c^{2} d^{4} \tan \left (f x + e\right )^{2} - 9 \, B c d^{5} \tan \left (f x + e\right )^{2} + 3 \, A d^{6} \tan \left (f x + e\right )^{2} - 3 \, C d^{6} \tan \left (f x + e\right )^{2} + 8 \, B c^{4} d^{2} \tan \left (f x + e\right ) - 22 \, A c^{3} d^{3} \tan \left (f x + e\right ) + 22 \, C c^{3} d^{3} \tan \left (f x + e\right ) - 18 \, B c^{2} d^{4} \tan \left (f x + e\right ) + 2 \, A c d^{5} \tan \left (f x + e\right ) - 2 \, C c d^{5} \tan \left (f x + e\right ) - 2 \, B d^{6} \tan \left (f x + e\right ) - C c^{6} + 6 \, B c^{5} d - 14 \, A c^{4} d^{2} + 11 \, C c^{4} d^{2} - 7 \, B c^{3} d^{3} - 3 \, A c^{2} d^{4} - B c d^{5} - A d^{6}}{{\left (c^{6} d + 3 \, c^{4} d^{3} + 3 \, c^{2} d^{5} + d^{7}\right )} {\left (d \tan \left (f x + e\right ) + c\right )}^{2}}}{2 \, f} \]

input
integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x, algorithm= 
"giac")
 
output
1/2*(2*(A*c^3 - C*c^3 + 3*B*c^2*d - 3*A*c*d^2 + 3*C*c*d^2 - B*d^3)*(f*x + 
e)/(c^6 + 3*c^4*d^2 + 3*c^2*d^4 + d^6) + (B*c^3 - 3*A*c^2*d + 3*C*c^2*d - 
3*B*c*d^2 + A*d^3 - C*d^3)*log(tan(f*x + e)^2 + 1)/(c^6 + 3*c^4*d^2 + 3*c^ 
2*d^4 + d^6) - 2*(B*c^3*d - 3*A*c^2*d^2 + 3*C*c^2*d^2 - 3*B*c*d^3 + A*d^4 
- C*d^4)*log(abs(d*tan(f*x + e) + c))/(c^6*d + 3*c^4*d^3 + 3*c^2*d^5 + d^7 
) + (3*B*c^3*d^3*tan(f*x + e)^2 - 9*A*c^2*d^4*tan(f*x + e)^2 + 9*C*c^2*d^4 
*tan(f*x + e)^2 - 9*B*c*d^5*tan(f*x + e)^2 + 3*A*d^6*tan(f*x + e)^2 - 3*C* 
d^6*tan(f*x + e)^2 + 8*B*c^4*d^2*tan(f*x + e) - 22*A*c^3*d^3*tan(f*x + e) 
+ 22*C*c^3*d^3*tan(f*x + e) - 18*B*c^2*d^4*tan(f*x + e) + 2*A*c*d^5*tan(f* 
x + e) - 2*C*c*d^5*tan(f*x + e) - 2*B*d^6*tan(f*x + e) - C*c^6 + 6*B*c^5*d 
 - 14*A*c^4*d^2 + 11*C*c^4*d^2 - 7*B*c^3*d^3 - 3*A*c^2*d^4 - B*c*d^5 - A*d 
^6)/((c^6*d + 3*c^4*d^3 + 3*c^2*d^5 + d^7)*(d*tan(f*x + e) + c)^2))/f
 
3.1.87.9 Mupad [B] (verification not implemented)

Time = 10.86 (sec) , antiderivative size = 327, normalized size of antiderivative = 1.56 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^3} \, dx=-\frac {\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (B\,d^3+2\,A\,c\,d^2-B\,c^2\,d-2\,C\,c\,d^2\right )}{c^4+2\,c^2\,d^2+d^4}+\frac {A\,d^4+C\,c^4+5\,A\,c^2\,d^2-3\,C\,c^2\,d^2+B\,c\,d^3-3\,B\,c^3\,d}{2\,d\,\left (c^4+2\,c^2\,d^2+d^4\right )}}{f\,\left (c^2+2\,c\,d\,\mathrm {tan}\left (e+f\,x\right )+d^2\,{\mathrm {tan}\left (e+f\,x\right )}^2\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (B-A\,1{}\mathrm {i}+C\,1{}\mathrm {i}\right )}{2\,f\,\left (-c^3-c^2\,d\,3{}\mathrm {i}+3\,c\,d^2+d^3\,1{}\mathrm {i}\right )}-\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (B\,c^3+\left (3\,C-3\,A\right )\,c^2\,d-3\,B\,c\,d^2+\left (A-C\right )\,d^3\right )}{f\,\left (c^6+3\,c^4\,d^2+3\,c^2\,d^4+d^6\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (C-A+B\,1{}\mathrm {i}\right )}{2\,f\,\left (-c^3\,1{}\mathrm {i}-3\,c^2\,d+c\,d^2\,3{}\mathrm {i}+d^3\right )} \]

input
int((A + B*tan(e + f*x) + C*tan(e + f*x)^2)/(c + d*tan(e + f*x))^3,x)
 
output
- ((tan(e + f*x)*(B*d^3 + 2*A*c*d^2 - B*c^2*d - 2*C*c*d^2))/(c^4 + d^4 + 2 
*c^2*d^2) + (A*d^4 + C*c^4 + 5*A*c^2*d^2 - 3*C*c^2*d^2 + B*c*d^3 - 3*B*c^3 
*d)/(2*d*(c^4 + d^4 + 2*c^2*d^2)))/(f*(c^2 + d^2*tan(e + f*x)^2 + 2*c*d*ta 
n(e + f*x))) - (log(tan(e + f*x) - 1i)*(B - A*1i + C*1i))/(2*f*(3*c*d^2 - 
c^2*d*3i - c^3 + d^3*1i)) - (log(c + d*tan(e + f*x))*(B*c^3 + d^3*(A - C) 
- c^2*d*(3*A - 3*C) - 3*B*c*d^2))/(f*(c^6 + d^6 + 3*c^2*d^4 + 3*c^4*d^2)) 
- (log(tan(e + f*x) + 1i)*(B*1i - A + C))/(2*f*(c*d^2*3i - 3*c^2*d - c^3*1 
i + d^3))